package com.eeds.controller.pc;

import com.eeds.base.BaseController;
import com.eeds.common.model.BaseWrapper;
import com.eeds.interceptor.NeedAuth;
import com.eeds.model.upload.req.ReqUploadBase64FileVO;
import com.eeds.model.upload.req.ReqUploadFileVO;
import com.eeds.model.upload.res.ResUploadFileVO;
import com.eeds.model.user.req.ReqDeleteUserVO;
import com.eeds.service.upload.UploadService;
import io.swagger.annotations.Api;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.validation.Valid;


@RestController
@Api(value = "角色接口", description = "角色接口")
@RequestMapping("pc/upload/")
@Slf4j
public class UploadController extends BaseController {

    @Autowired
    private UploadService uploadService;


    /**
     * description:上传文件
     * @author: Flying
     * @date: 2018-08-28 12:31
     * @param: null
     * @return
     */
    @NeedAuth
    @RequestMapping(value = "uploadFile",method = RequestMethod.POST)
    public BaseWrapper<ResUploadFileVO> uploadFile(@Valid @ModelAttribute ReqUploadFileVO reqUploadFileVO,@RequestParam("file") MultipartFile file) {
        reqUploadFileVO.setUploadfile(file);
        ResUploadFileVO result = uploadService.uploadFile(reqUploadFileVO);
        return new BaseWrapper<>(result);
    }



    @NeedAuth
    @RequestMapping(value = "uploadBase64File",method = RequestMethod.POST)
    public BaseWrapper<ResUploadFileVO> uploadBase64File( @RequestBody ReqUploadBase64FileVO storeData ) {
        ResUploadFileVO result = uploadService.uploadBase64File(storeData);
        return new BaseWrapper<>(result);
    }
}
